//
// Created by liaoy on 2021/8/19.
//

#include "syscall.h"
#include <stdio.h>

reg_t syscall(uint16_t id, uint8_t *params)
{
    reg_t ret;
    memset(&ret, 0, sizeof(reg_t));
    switch (id)
    {
        case TEST1:
            ret.content.integer = 1;
            printf("%c%c%c%c\n", params[0], params[1], params[2], params[3]);
            break;
        case TEST2:
            ret.content.integer = 1;
            printf("0x%x%x%x%x\n", params[0], params[1], params[2], params[3]);
            break;
        case STR_PRINT:
            ret.content.integer = 1;
            printf("%s", (char *) params);
            break;
        case PTR_STR_PRINT:
            ret.content.integer = 1;
            printf("%s", (char *) *((int64_t *) params));
            break;
        case INT_PRINT:
            printf("%d", *((int *) params));
            ret.content.integer = 1;
            break;
        default:
            ret.content.integer = -1;
            break;
    }
    return ret;
}